package com.example.lhsama.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.lhsama.domain.Role;
import com.example.lhsama.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Iterator;
import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where user_name = #{userName}")
    User selectByName(String userName);

    @Select("select * from role where id in (select rid from user_role where uid=#{uid})")
    List<Role> getRolesList(Integer uid);

    @Delete("delete from user_role where uid = #{uid}")
    void deleteRoleByUid(Integer uid);


}

